<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->engine='InnoDB';
            $table->increments('id')->comment('产品编号');
	        $table->text('describe')->comment('描述');
			$table->string('product_name')->comment('产品名称');
			$table->unsignedInteger('type_id')->nullable()->default(0)->comment('产品类型');
            $table->string('specifications')->comment('产品规格');
            $table->float('cost_price')->default(0.0)->comment('成本价');
            $table->float('retail_price')->default(0.0)->comment('零售价');
		    $table->text('image')->comment('零售价');
			$table->text('Remark')->comment('备注');
			$table->foreign('type_id')->references('id')->on('product_types')->onUpdate('cascade')->onDelete('cascade');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('products');
    }
}
